<%@page import="cn.com.entity.Doctor"%>
<%@page import="cn.com.entity.Departments"%>
<%@page import="java.util.List"%>
<%@page import="cn.com.dao.DepartmentsDao"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>管理员修改医生信息</title>
<style type="text/css">
#main{
	margin-top: 5%
}
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">

function yanzheng(){
	//定义一个正则表达式，数字和字母组成，4-25位之间
		var reg=/^[A-Za-z0-9]{4,25}$/; 
		if(!reg.test($("#doctorname").val())){
			alert("用户名只能是字母和数字，必须在4到25位之间");
			return false;
			}
		var reg1=/^\S+$/;	
		if(!reg1.test($("#doctorrealname").val())){
			alert("姓名不能为空");
			return false;
			}
		//验证手机号
		var reg3=/^1[3|5][0-9]\d{4,8}$/; 
		if(!reg3.test($("#doctorphone").val())){
			alert("请填写正确的11位手机号码");
			return false;
			}
		
		if(!reg1.test($("#doctorworktime").val())){
			alert("医生工作时间不能为空");
			return false;	
			}
		
		if(!reg1.test($("#doctorprofile").val())){
			alert("医生简介不能为空");
			return false;	
			}
		if(!reg1.test($("#doctordesignation").val())){
			alert("医生职称不能为空");
			return false;	
			}
	
		return true;
			
		}

</script>
</head>
<body>
<div id="main">
<form method="post" action="updatedoctoraction" onsubmit="return yanzheng()">
<h2 align="center">医生信息修改</h2>
<center>${doctormsg}</center>
<% 
if(session.getAttribute("onedoctorlist")!=null){
	Doctor  d=(Doctor)session.getAttribute("onedoctorlist");
%>
	<table align="center" width="50%">
		<tr>
			<td>用户名：</td>
			<td>
			<input type="hidden" value="<%=d.getDoctorid() %>" name="doctor.doctorid"/>	
			<input type="text" name="doctor.doctorname" id="doctorname" value="<%=d.getDoctorname()%>"/></td>
		</tr>
		
		<tr>
			<td>姓名：
			<input type="hidden" value="<%=d.getDoctorpwd() %>" name="doctor.doctorpwd"/>
			</td>
			<td><input type="text" value="<%=d.getDoctorrealname() %>" name="doctor.doctorrealname" id="doctorrealname"/></td>
		</tr>
		
		<tr>
			<td>联系方式：
			<input type="hidden" value="<%=d.getDoctorsex() %>" name="doctor.doctorsex"/>
			</td>
			<td><input type="text" value="<%=d.getDoctorphone() %>" name="doctor.doctorphone" id="doctorphone"/></td>
		</tr>
		
		<tr>
			<td>工作时间：
			</td>
			<td><input type="text" value="<%=d.getDoctorworktime() %>" name="doctor.doctorworktime" id="doctorworktime"/></td>
		</tr>
		
		<tr>
			<td>医生简介：
			</td>
			<td>
			<textarea rows="3" cols="20" name="doctor.doctorprofile" id="doctorprofile"><%=d.getDoctorprofile() %></textarea>
			</td>
		</tr>
		
		<tr>
			<td>医生职称：
			</td>
			<td><input type="text" value="<%=d.getDoctordesignation() %>" name="doctor.doctordesignation" id="doctordesignation"/></td>
		</tr>
		
		<tr>
			<td>所属科室：
			</td>
			<td>
				<select name="doctor.departmentsid">
<%
DepartmentsDao dd=new DepartmentsDao();
List<Departments> list=(List<Departments>)dd.selectAlldeDepartments();
for(int i=0;i<list.size();i++){
	Departments depart=list.get(i);
%>					
					<option value="<%=depart.getDepartmentsid() %>"><%=depart.getDepartmentsname() %></option>
<%} %>					
				</select>
			</td>
		</tr>
		
		<tr>
			<td align="center" colspan="2"><input type="submit"  value=" 保存  " style="font-size:20px; color:#FFF; background-image: url(images/lanseanniu.jpg);"/></td>
		</tr>
	</table>
<%} %>
</form>
</div>
</body>
</html>